// $(document).ready(function () {

    // function getSIMDetail(pagesize,page) {
    //     if (socket) {
    //         var data = { itemsPerPage: pagesize, currentPage: page};
    //         console.log("select");
    //         socket.emit('data_sim_select', data);
    //     }
    // }
    // var pageIndex_record = 1;
    
    // getSIMDetail(5, pageIndex_record);

    // socket.on('data_sim', function (receivedata, itemcount) {
    //     console.log("receive data" + receivedata);

    // });
    

    $("#jqGrid").jqGrid({
        // data: receivedata,
        url: select_url + 'sim',
        // we set the changes to be made at client side using predefined word clientArray
        editurl: edit_url + 'sim',
        mtype: 'POST',
        datatype: "json",
        colModel: [
            {
                label: '序号',
                name: 'id',
                width: 50,
                key: true,
                editable: false,
                editrules : { required: true},
                hidden: true
            },
            {
                label: '客户名称',
                name: 'org',
                width: 120,
                editable: true
            },
            {
                label : 'SIM卡号码',
                name: 'mobile',
                width: 150,
                editable: true
            },
            {
                label: '启用日期',
                name: 'startday',
                width: 200,
                editable: true,
                // edittype: 'datetime-local',
                // editrules:{edithidden:true,required:true,date:true},
                fixed: true, formatter: 'date',
                formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'},
                // formatter: function(){
                //     $("#startday").attr("class","FormElement form-control");
                // },
                // formatoptions: { newformat: 'yyyy-mm-dd' },
                // editrules: { custom: true, custom_func: date_check1 },
                // editoptions: { 
                //     dataInit: function(element) { 
                //         $(element).datetimepicker({ 
                //             // dateFormat: 'yy-mm-dd hh:mm:ss',
                //             language:  'zh',  
                //             weekStart: 1,  
                //             todayBtn:  1,  
                //             autoclose: 1,  
                //             todayHighlight: 1,  
                //             startView: 2,  
                //             forceParse: 0,  
                //             showMeridian: 1,

                //         }).on('changeDate', function (ev) {  
                //             $(this).datetimepicker('hide');  
                //         });
                //             // changeMonth: true,
                //             // changeYear: true })
                //     }
                // } 
            },
            {
                label: '套餐费用',
                name: 'fee',
                width: 80,
                editable: true
            },
            {
                label: '每月流量',
                name: 'flow',
                width: 80,
                editable: true
            },
            {
                label : '运营商',
                name: 'yys',
                width: 100,
                editable: true
            },
            {
                label: '业务类型',
                name: 'ywlx',
                width: 150,
                editable: true
            },
            {
                label: '是否绑定',
                name: 'bd',
                width: 100,
                editable: true,
                edittype:'select',formatter : 'select',
                editoptions : {
                    value:"1 : 是; 0 : 否"
                }
            },
            {
                label: '描述',
                name: 'des',
                width: 180,
                editable: true
            },
            {//行编辑
                label: "操作",
                name: "actions",
                width: 100,
                formatter: "actions",
                formatoptions: {
                    keys: true,
                    editOptions: {},
                    addOptions: {},
                    delOptions: {}
                }       
            }
        ],

        jsonReader: {
            root: 'rows',
            repeatitems : false,
            id: "0"
        },
        rowNum:10,
        rowList:[10,20,30],
        sortname: 'id',
        sortorder : 'desc',//正序
        viewrecords: true,
        // styleUI : 'Bootstrap',
        rownumbers: true, //行序号
        rownumWidth: 25,
        multiselect: true,//复选框
        width: "100%",
        height: 350,
        pager: "#jqGridPager"
    });


    var template = "<div style='margin-left:15px;'><div> 客户名称 <sup>*</sup>:</div><div>{org} </div>";
    template += "<div> SIM卡号码: </div><div>{mobile} </div>";
    template += "<div> 启用日期: </div><div>{startday} </div>";
    template += "<div> 套餐费用:</div><div> {fee} </div>";
    template += "<div> 每月流量: </div><div>{flow} </div>";
    template += "<div> 运营商: </div><div>{yys} </div>";
    template += "<div> 业务类型: </div><div>{ywlx} </div>";
    template += "<div> 是否绑定:</div><div> {bd} </div>";
    template += "<div> 描述:</div><div> {des} </div>";
    template += "<hr style='width:100%;'/>";
    template += "<div> {sData} {cData}  </div></div>";

    

    $('#jqGrid').navGrid('#jqGridPager',
        // the buttons to appear on the toolbar of the grid
        { edit: true, add: true, del: true, search: false, refresh: true, view: false, position: "left", cloneToTop: false },
        // Edit Dialog
        {
            editCaption: "修改SIM卡信息",
        },
        // Add Dialog
        {
            addCaption: "添加SIM卡信息",
        }
    );

    //查询
    var mobile_mask = $("#s_mobile").val();
    var client_mask = $("#s_org").val();
    gridReload("sim?mobile="+mobile_mask+"&org="+client_mask);

    
// });